<script setup lang="ts">
import NewMenu from "@/components/NewMenu.vue";
import {useRouterStore} from "@/stores/router";
import {ref} from "vue";
import {type NavigationGuard, onBeforeRouteUpdate, useRoute} from "vue-router";
const routerStore = useRouterStore()

const routerList = routerStore.getRouterList();
let activeRouteName = ref()

const route = useRoute()
activeRouteName.value = route.name

onBeforeRouteUpdate((updateGuard:NavigationGuard) => {
  activeRouteName.value = updateGuard.name
})
</script>
<template>
  <el-menu router :default-active="activeRouteName">
    <new-menu v-for="(route, index) in routerList" :route="route" :key="index"/>
  </el-menu>
</template>
<style scoped></style>